package com.blb.common.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.common.entity.Product;
import com.blb.common.entity.ResponseResult;
import com.blb.common.fallback.ProductServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 调用商品服务的客户端
 */
@FeignClient(value = "product-service",fallback = ProductServiceFallback.class)
public interface ProductServiceClient {

    @GetMapping("product/{id}")
    Product getProductById(@PathVariable Long id);

    @GetMapping("product-page")
    ResponseResult<Page<Product>> getProductPage(@RequestParam(required = false, defaultValue = "1") Long current,
                                                 @RequestParam(required = false, defaultValue = "10") Long size);

    @PostMapping("product")
    ResponseResult<String> addProduct(@RequestBody Product product);

    @PutMapping("product")
    ResponseResult<String> updateProduct(@RequestBody Product product);

    @DeleteMapping("product/{id}")
    ResponseResult<String> removeProduct(@PathVariable Long id);
}
